import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBNetWorkModule/YBAPi/YBAPi.dart';


class YBNewFindMainDetailPage extends StatefulWidget {

  final int id;
  const YBNewFindMainDetailPage({Key key, this.id}) : super(key: key);

  @override
  _YBNewFindMainDetailPageState createState() => _YBNewFindMainDetailPageState(id);
}

class _YBNewFindMainDetailPageState extends State<YBNewFindMainDetailPage> {

  final int id;

  _YBNewFindMainDetailPageState(this.id);

  Completer<WebViewController> _controller = Completer<WebViewController>();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    if (Platform.isAndroid) {
      WebView.platform = SurfaceAndroidWebView();
    }
  }

  @override
  void dispose() {
    // TODO: implement dispose
    EasyLoading.dismiss();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        appBar: AppBar(
          title: Text(YBChineseText.findWenZhangDetailTitle),
          elevation: 0,
        ),

        body: WebView(
          initialUrl: '${YBApi.Base_QuanCeng_URL}/$id?type=1',
          onWebViewCreated: (WebViewController controller){
            _controller.complete(controller);
          },
          onPageFinished: (url){
            EasyLoading.dismiss();
          },
          onPageStarted: (url){
            EasyLoading.show(status: "读取中...");
          },
          javascriptMode: JavascriptMode.unrestricted,

        ),
      ),
    );
  }
}

